package com.ai.util;

import java.util.ArrayList;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.ai.academiainteligente.*;

public class EventoAdapter extends BaseAdapter {

	ArrayList<Evento> eventos;

	public EventoAdapter(ArrayList<Evento> academias) {
		this.eventos = academias;
	}

	@Override
	public int getCount() {
		return eventos.size();
	}

	@Override
	public Object getItem(int arg0) {
		return eventos.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Evento evento = eventos.get(position);
		ViewHolder holder;
		if (convertView == null) {
			convertView = LayoutInflater.from(parent.getContext()).inflate(
					R.layout.item_evento, null);
			holder = new ViewHolder();
			holder.txtDescricao = (TextView) convertView
					.findViewById(R.id.txtDescricao);
			holder.txtData = (TextView) convertView.findViewById(R.id.txtData);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.txtDescricao.setText(evento.getDescricao());
		holder.txtData.setText(evento.getData());
		return convertView;
	}

	static class ViewHolder {
		TextView txtDescricao;
		TextView txtData;
	}

}
